//
// Created by jinyf on 2022/3/2.
//

#ifndef INC_54_FFMPEG_MP3PLAYER_MNFFMPEG_H
#define INC_54_FFMPEG_MP3PLAYER_MNFFMPEG_H


#include "MNPlaystatus.h"
#include "MNCallJava.h"

#include "pthread.h"
#include "MNAudio.h"
#include "MNPlaystatus.h"

extern "C"
{
#include "libavformat/avformat.h"
#include "libavutil/time.h"
};


class MNFFmpeg {

public:
    MNCallJava *callJava = NULL;
    const char *url = NULL;
    pthread_t decodeThread;
    AVFormatContext *pFormatCtx = NULL;

    MNAudio *audio = NULL;
    MNPlaystatus *playstatus = NULL;

    pthread_mutex_t seek_mutex;

    pthread_mutex_t init_mute;

    bool exit = false;

public:
    MNFFmpeg(MNPlaystatus *playstatus, MNCallJava *callJava, const char *url);

    ~MNFFmpeg();

    void parpared();

    void decodeFFmpegThread();

    void start();

    void seek(int i);

    void pause();

    void resume();

    void setMute(int i);

    void setSpeed(float d);

    void setPitch(float d);

    void release();
};


#endif //INC_54_FFMPEG_MP3PLAYER_MNFFMPEG_H
